4
4
.
.
4
4
.
.
3
3
R
R
o
o
u
u
n
n
d
d
e
e
d
d
R
R
e
e
c
c
t
t
a
a
n
n
g
g
l
l
e
e
I
I
n
n
f
f
o
o
[
[
R
R
]
]
This tutorials shows how to add View in the shape of the RoundedRectangle.
You can't combine fill and stroke on the same RoundedRectangle.
Style parameter determines whether you want
● .circular classic rounded corners
● .continuous Apple’s slightly smoother alternative
Fill
struct ContentView : View {
var body : some View {
RoundedRectangle(cornerRadius: 20, style: .continuous)
.rotation(.degrees(45))
.fill(Color.green)
.frame(width: 100, height: 100)
}
}
Stroke
struct ContentView : View {
var body : some View {
RoundedRectangle(cornerRadius: 20, style: .circular)
.rotation(.degrees(45))
.stroke(Color.green, lineWidth: 2)
.frame(width: 100, height: 100)
}
}
Fill Stroke